package customerEnter.Frame.conntroller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import customerEnter.Frame.Utils.Log4j;

/**
 * 
 * 
 * 类名称：BaseConntrollerFrameConntroView 类描述： 创建人：dy 创建时间：2016-9-1 下午4:48:06
 * 
 */
public class BaseConntrollerFrameConntroView {

	protected HttpServletRequest	request;
	protected HttpServletResponse	response;

	// protected String RequestDispatcherPaht;
	// protected String Redirect;

	public BaseConntrollerFrameConntroView(HttpServletRequest request, HttpServletResponse response) {
		this.request = request;
		this.response = response;
		Log4j.setLog4j(getClass());
	}

	/**
	 * 設置request作用域值
	 */
	public void setAttribute(String name, Object o) {
		request.setAttribute(name, o);
	}

	/**
	 * 獲取session
	 */
	public HttpSession getSession() {
		return request.getSession();
	}

	/**
	 * 轉發
	 */
	public void RequestDispatcher(String path) {
		// this.RequestDispatcherPaht = path;
		try {
			request.getRequestDispatcher(path).forward(request, response);
		} catch (Exception e) {
			Log4j.Log4JOutError(e.getMessage());
		}
	}

	/**
	 * 重定向
	 */
	public void Redirect(String path) {
		// this.Redirect = path;
		try {
			response.sendRedirect(path);
		} catch (Exception e) {
			Log4j.Log4JOutError(e.getMessage());
		}
	}

}
